<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>objectivec基础用法 | 茂茂个人博客</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="https://pan.zealsay.com/blog/favicon.ico">
    <script>
          var _hmt = _hmt || [];
          (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?b0aae218897fa9d8a9f76e9a77e0b3c6";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
          })();
        </script>
    <meta name="description" content="开心最重要呀">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/blog/assets/css/0.styles.ed123d92.css" as="style"><link rel="preload" href="/blog/assets/js/app.e4cba77b.js" as="script"><link rel="preload" href="/blog/assets/js/5.1ad0ff24.js" as="script"><link rel="preload" href="/blog/assets/js/1.fe4eac58.js" as="script"><link rel="preload" href="/blog/assets/js/27.0c4acdea.js" as="script"><link rel="prefetch" href="/blog/assets/js/10.58980e71.js"><link rel="prefetch" href="/blog/assets/js/11.461ee1ab.js"><link rel="prefetch" href="/blog/assets/js/12.de9aade4.js"><link rel="prefetch" href="/blog/assets/js/13.c1f7abfc.js"><link rel="prefetch" href="/blog/assets/js/14.eeee4da5.js"><link rel="prefetch" href="/blog/assets/js/15.225a74ee.js"><link rel="prefetch" href="/blog/assets/js/16.3eef12b1.js"><link rel="prefetch" href="/blog/assets/js/17.a97bd7c7.js"><link rel="prefetch" href="/blog/assets/js/18.461a74bd.js"><link rel="prefetch" href="/blog/assets/js/19.7b390d19.js"><link rel="prefetch" href="/blog/assets/js/20.8638de7c.js"><link rel="prefetch" href="/blog/assets/js/21.8b1e5c62.js"><link rel="prefetch" href="/blog/assets/js/22.b6b97b5b.js"><link rel="prefetch" href="/blog/assets/js/23.c3e9364b.js"><link rel="prefetch" href="/blog/assets/js/24.daa0ce9e.js"><link rel="prefetch" href="/blog/assets/js/25.0c44cdb2.js"><link rel="prefetch" href="/blog/assets/js/26.ed604668.js"><link rel="prefetch" href="/blog/assets/js/28.4f896280.js"><link rel="prefetch" href="/blog/assets/js/29.50e69b67.js"><link rel="prefetch" href="/blog/assets/js/3.90606e56.js"><link rel="prefetch" href="/blog/assets/js/30.5c69a6a2.js"><link rel="prefetch" href="/blog/assets/js/31.8a40c25d.js"><link rel="prefetch" href="/blog/assets/js/32.7a1f46ed.js"><link rel="prefetch" href="/blog/assets/js/33.a48429b4.js"><link rel="prefetch" href="/blog/assets/js/34.8f224bd0.js"><link rel="prefetch" href="/blog/assets/js/35.bc552eb5.js"><link rel="prefetch" href="/blog/assets/js/36.7e0cc0d9.js"><link rel="prefetch" href="/blog/assets/js/37.2bb21bfb.js"><link rel="prefetch" href="/blog/assets/js/38.f77b014f.js"><link rel="prefetch" href="/blog/assets/js/39.8a5ba8b0.js"><link rel="prefetch" href="/blog/assets/js/4.89c80be7.js"><link rel="prefetch" href="/blog/assets/js/40.c600c684.js"><link rel="prefetch" href="/blog/assets/js/41.0dbac397.js"><link rel="prefetch" href="/blog/assets/js/42.f1035a7b.js"><link rel="prefetch" href="/blog/assets/js/43.ace95e0e.js"><link rel="prefetch" href="/blog/assets/js/44.0ff283b9.js"><link rel="prefetch" href="/blog/assets/js/45.836151e7.js"><link rel="prefetch" href="/blog/assets/js/46.033824d7.js"><link rel="prefetch" href="/blog/assets/js/47.499ce120.js"><link rel="prefetch" href="/blog/assets/js/48.39c2db90.js"><link rel="prefetch" href="/blog/assets/js/49.ca266dff.js"><link rel="prefetch" href="/blog/assets/js/50.c12ee57e.js"><link rel="prefetch" href="/blog/assets/js/51.4c3c8a1c.js"><link rel="prefetch" href="/blog/assets/js/52.c11bc4a4.js"><link rel="prefetch" href="/blog/assets/js/53.d4dc4ec7.js"><link rel="prefetch" href="/blog/assets/js/54.300dd272.js"><link rel="prefetch" href="/blog/assets/js/55.6e86af02.js"><link rel="prefetch" href="/blog/assets/js/56.d91a04d8.js"><link rel="prefetch" href="/blog/assets/js/6.4f77b856.js"><link rel="prefetch" href="/blog/assets/js/7.db9a864b.js"><link rel="prefetch" href="/blog/assets/js/8.bf0cca83.js"><link rel="prefetch" href="/blog/assets/js/9.84ddd18e.js">
    <link rel="stylesheet" href="/blog/assets/css/0.styles.ed123d92.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-0c5314fc><div data-v-0c5314fc><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-0c5314fc data-v-0c5314fc><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-5cb9a64e data-v-0c5314fc data-v-0c5314fc><h3 class="title" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e>茂茂个人博客</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><input type="password" value="" data-v-5cb9a64e> <span data-v-5cb9a64e>Konck! Knock!</span> <button data-v-5cb9a64e>OK</button></label> <div class="footer" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><span data-v-5cb9a64e><i class="iconfont reco-theme" data-v-5cb9a64e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-5cb9a64e>vuePress-theme-reco</a></span> <span data-v-5cb9a64e><i class="iconfont reco-copyright" data-v-5cb9a64e></i> <a data-v-5cb9a64e><span data-v-5cb9a64e>茂茂</span>
            
          <span data-v-5cb9a64e>2019 - </span>
          2023
        </a></span></div></div> <div class="hide" data-v-0c5314fc><div data-v-0c5314fc><div id="smart" class="wrapper-page" style="background-image:url(/blog/articleImage/img06.jpeg);background-position-x:center;background-position-y:center;background-size:cover;background-repeat-x:no-repeat;background-repeat-y:no-repeat;" data-v-0c5314fc><header class="navbar" data-v-0c5314fc><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/blog/" class="home-link router-link-active"><img src="/blog/logo.png" alt="茂茂个人博客" class="logo"> <span class="site-name">茂茂个人博客</span></a> <div class="links"><div id="dayNightSwitch" class="generalWrapper" data-v-32f44868><a class="click" data-v-32f44868><div class="onOff daySwitch" data-v-32f44868><div class="star star1" data-v-32f44868></div> <div class="star star2" data-v-32f44868></div> <div class="star star3" data-v-32f44868></div> <div class="star star4" data-v-32f44868></div> <div class="star star5" data-v-32f44868></div> <div class="star sky" data-v-32f44868></div> <div class="sunMoon" data-v-32f44868><div class="crater crater1" data-v-32f44868></div> <div class="crater crater2" data-v-32f44868></div> <div class="crater crater3" data-v-32f44868></div> <div class="cloud part1" data-v-32f44868></div> <div class="cloud part2" data-v-32f44868></div></div></div></a></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/blog/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      博客
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/categories/工具与阅读/" class="nav-link"><i class="iconfont undefined"></i>
  工具与阅读
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/vue/" class="nav-link"><i class="iconfont undefined"></i>
  vue
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/前端/" class="nav-link"><i class="iconfont undefined"></i>
  前端
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/node/" class="nav-link"><i class="iconfont undefined"></i>
  node
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/IOS/" class="nav-link"><i class="iconfont undefined"></i>
  IOS
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/WebGIS/" class="nav-link"><i class="iconfont undefined"></i>
  WebGIS
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/React/" class="nav-link"><i class="iconfont undefined"></i>
  React
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/面试/" class="nav-link"><i class="iconfont undefined"></i>
  面试
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/Angular/" class="nav-link"><i class="iconfont undefined"></i>
  Angular
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/数据结构与算法/" class="nav-link"><i class="iconfont undefined"></i>
  数据结构与算法
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/微前端架构/" class="nav-link"><i class="iconfont undefined"></i>
  微前端架构
</a></li></ul></div></div><div class="nav-item"><a href="/blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间轴
</a></div><div class="nav-item"><a href="/blog/about/" class="nav-link"><i class="iconfont reco-account"></i>
  关于
</a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-0c5314fc></div> <aside class="sidebar" data-v-0c5314fc><div class="personal-info-wrapper" data-v-03833281 data-v-0c5314fc><img src="/blog/logo.png" alt="author-avatar" class="personal-img" data-v-03833281> <h3 class="name" data-v-03833281>
    茂茂
  </h3> <div class="num" data-v-03833281><div data-v-03833281><h3 data-v-03833281>43</h3> <h6 data-v-03833281>文章</h6></div> <div data-v-03833281><h3 data-v-03833281>30</h3> <h6 data-v-03833281>标签</h6></div></div> <hr data-v-03833281></div> <nav class="nav-links"><div class="nav-item"><a href="/blog/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      博客
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/categories/工具与阅读/" class="nav-link"><i class="iconfont undefined"></i>
  工具与阅读
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/vue/" class="nav-link"><i class="iconfont undefined"></i>
  vue
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/前端/" class="nav-link"><i class="iconfont undefined"></i>
  前端
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/node/" class="nav-link"><i class="iconfont undefined"></i>
  node
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/IOS/" class="nav-link"><i class="iconfont undefined"></i>
  IOS
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/WebGIS/" class="nav-link"><i class="iconfont undefined"></i>
  WebGIS
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/React/" class="nav-link"><i class="iconfont undefined"></i>
  React
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/面试/" class="nav-link"><i class="iconfont undefined"></i>
  面试
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/Angular/" class="nav-link"><i class="iconfont undefined"></i>
  Angular
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/数据结构与算法/" class="nav-link"><i class="iconfont undefined"></i>
  数据结构与算法
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/微前端架构/" class="nav-link"><i class="iconfont undefined"></i>
  微前端架构
</a></li></ul></div></div><div class="nav-item"><a href="/blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间轴
</a></div><div class="nav-item"><a href="/blog/about/" class="nav-link"><i class="iconfont reco-account"></i>
  关于
</a></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-5cb9a64e data-v-0c5314fc><h3 class="title" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e>objectivec基础用法</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><input type="password" value="" data-v-5cb9a64e> <span data-v-5cb9a64e>Konck! Knock!</span> <button data-v-5cb9a64e>OK</button></label> <div class="footer" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><span data-v-5cb9a64e><i class="iconfont reco-theme" data-v-5cb9a64e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-5cb9a64e>vuePress-theme-reco</a></span> <span data-v-5cb9a64e><i class="iconfont reco-copyright" data-v-5cb9a64e></i> <a data-v-5cb9a64e><span data-v-5cb9a64e>茂茂</span>
            
          <span data-v-5cb9a64e>2019 - </span>
          2023
        </a></span></div></div></div> <div data-v-0c5314fc><main class="page" style="padding-right:0;"><div class="page-title" style="display:none;"><h1 class="title">objectivec基础用法</h1> <div class="page-info" data-v-0efa1f05><i class="iconfont reco-account" data-v-0efa1f05><span data-v-0efa1f05>茂茂</span></i> <i class="iconfont reco-date" data-v-0efa1f05><span data-v-0efa1f05>2019-09-26</span></i> <i class="iconfont reco-eye" data-v-0efa1f05><span id="/blog/blogs/tec/2019/092106.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-0efa1f05><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="iconfont reco-tag tags" data-v-0efa1f05><span class="tag-item" data-v-0efa1f05>Objective-C</span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><h1 id="ios"><a href="#ios" class="header-anchor">#</a> IOS</h1> <h2 id="视图控制器"><a href="#视图控制器" class="header-anchor">#</a> 视图控制器</h2> <h3 id="基本用法"><a href="#基本用法" class="header-anchor">#</a> 基本用法</h3> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code>   CGRect rect1 <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//初始化一个矩形显示区域对象，</span>
    UIView <span class="token operator">*</span>view1 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span>rect1<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个视图对象</span>
    view1<span class="token punctuation">.</span>backgroundColor<span class="token operator">=</span><span class="token punctuation">[</span>UIColor brownColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//颜色设置</span>
    
    CGRect rect2 <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">90</span><span class="token punctuation">,</span> <span class="token number">120</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//初始化一个矩形显示区域对象，</span>
    UIView <span class="token operator">*</span>view2 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span>rect2<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个视图对象</span>
    view2<span class="token punctuation">.</span>backgroundColor<span class="token operator">=</span><span class="token punctuation">[</span>UIColor purpleColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//颜色设置</span>
    
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view1<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到视图控制器的根视图</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view2<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到视图控制器的根视图</span>
视图的层次（父子）

UIView <span class="token operator">*</span>view1 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span><span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">80</span><span class="token punctuation">,</span> <span class="token number">280</span><span class="token punctuation">,</span> <span class="token number">280</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    view1<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor redColor<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view1<span class="token punctuation">]</span><span class="token punctuation">;</span>
    
    UIView <span class="token operator">*</span>view2 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span><span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    view2<span class="token punctuation">.</span>bounds <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">40</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//设置视图本地坐标系统中的位置和大小，会影响子视图的位置和显示</span>
    view2<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor yellowColor<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view2<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到视图控制器的根视图</span>
    
    UIView <span class="token operator">*</span>view3 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span><span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    view3<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor blueColor<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>view2 addSubview<span class="token punctuation">:</span>view3<span class="token punctuation">]</span><span class="token punctuation">;</span>
</code></pre></div><img src="/blog/shitu01.png" alt="foo"> 
```objectivec
视图的基本添加删除操作
   CGRect rect1 = CGRectMake(30, 50, 200, 200);//初始化一个矩形显示区域对象，
    UIView *view1 = [[UIView alloc] initWithFrame:rect1];//创建一个视图对象
    view1.backgroundColor=[UIColor brownColor];//颜色设置
    [self.view addSubview:view1];
<div class="language- extra-class"><pre><code>UIButton *btAdd = [[UIButton alloc] initWithFrame:CGRectMake(30, 350, 80, 30)];//设置一个按钮
btAdd.backgroundColor =[UIColor grayColor];//添加一个按钮颜色
[btAdd setTitle:@&quot;Add&quot; forState:UIControlStateNormal];//设置按钮正常状态下的标题，其他状态还包括按钮被按下等状态
[btAdd addTarget:self action:@selector(addView) forControlEvents:UIControlEventTouchUpInside];//给按钮绑定点击事件，这样点击按钮时，将执行添加视图方法
[self.view addSubview:btAdd];//将按钮添加到视图控制器的根视图
//切换试图顺序
UIButton *btBack = [[UIButton alloc] initWithFrame:CGRectMake(120, 350, 80, 30)];//设置一个按钮
btBack.backgroundColor =[UIColor grayColor];//添加一个按钮颜色
[btBack setTitle:@&quot;Switch&quot; forState:UIControlStateNormal];//设置按钮正常状态下的标题，其他状态还包括按钮被按下等状态
[btBack addTarget:self action:@selector(bringViewBack) forControlEvents:UIControlEventTouchUpInside];//给按钮绑定点击事件，这样点击按钮时，将交换视图的层次
[self.view addSubview:btBack];//将按钮添加到视图控制器的根视图

UIButton *btRemove = [[UIButton alloc] initWithFrame:CGRectMake(210, 350, 80, 30)];//设置一个按钮
btRemove.backgroundColor =[UIColor grayColor];//添加一个按钮颜色
[btRemove setTitle:@&quot;Remove&quot; forState:UIControlStateNormal];//设置按钮正常状态下的标题，其他状态还包括按钮被按下等状态
[btRemove addTarget:self action:@selector(removeView) forControlEvents:UIControlEventTouchUpInside];//给按钮绑定点击事件，这样点击按钮时，将交换视图的层次
[self.view addSubview:btRemove];//将按钮添加到视图控制器的根视图
</code></pre></div><p>}</p> <ul><li><p>(void) addView
{
CGRect rect = CGRectMake(60, 90, 200, 200);//初始化一个矩形显示区域对象，
UIView *view = [[UIView alloc] initWithFrame:rect];//创建一个视图对象
view.backgroundColor=[UIColor purpleColor];//颜色设置
view.tag=1;//给视图指定一个标志，可通过标志找到视图
[self.view addSubview:view];//将按钮添加到视图控制器的根视图
}</p></li> <li><p>(void) bringViewBack
{
UIView *view = [self.view viewWithTag:1];//通过刚刚设置的标志找到新添加的视图
[self.view sendSubviewToBack:view];//将新添加的视图移到所有兄弟视图的后方
}</p></li> <li><p>(void) removeView
{
UIView *view = [self.view viewWithTag:1];//通过刚刚设置的标志找到新添加的视图
[view removeFromSuperview];//将新添加的视图从父视图中删除</p></li></ul> <p>}</p> <div class="language- extra-class"><pre class="language-text"><code>视图编写相框
```objectivec
UIImage *image = [UIImage imageNamed:@&quot;01&quot;];//加载图片
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];//图片的容器
    imageView.frame = CGRectMake(24, 80, 272, 410);//初始化图像位置
    imageView.layer.borderWidth=10;//设置图像视图的图层边框宽度
    imageView.layer.borderColor= [UIColor lightGrayColor].CGColor;//通过访问视图图层属性设置相关属性
    [self.view addSubview:imageView];//将图层添加到视图控制器的根视图
&lt;img :src=&quot;$withBase('/shitu02.png')&quot; alt=&quot;foo&quot;&gt; 
添加圆角效果
UIImage *image = [UIImage imageNamed:@&quot;01&quot;];//加载图片
        UIImageView *imageView = [[UIImageView alloc] initWithImage:image];//图片的容器
        imageView.frame = CGRectMake(24, 80, 300, 300);//初始化图像位置
        imageView.layer.cornerRadius=150;//设置圆角为一半
        imageView.layer.masksToBounds=true;//设置图像视图层的遮罩覆盖属性，进行边界裁切
        [self.view addSubview:imageView];//将图层添加到视图控制器的根视图
</code></pre></div><img src="/blog/shitu03.png" alt="foo"> 
图像阴影效果
```objectivec
UIImage *image = [UIImage imageNamed:@&quot;01&quot;];//加载图片
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];//图片的容器
    imageView.frame = CGRectMake(36, 80, 272,164);//初始化图像位置
    imageView.layer.shadowColor =[UIColor blackColor].CGColor;//阴影颜色为黑色
    imageView.layer.shadowOffset = CGSizeMake(10.0, 10.0);//设置横向和纵向偏移
    imageView.layer.shadowOpacity=0.45;//阴影透明度
    imageView.layer.shadowRadius=10;//阴影半径大小
    [self.view addSubview:imageView];
```
<img src="/blog/shitu04.png" alt="foo"> 
渐变填充
```
CGRect rect =CGRectMake(30, 60, 200, 200);
    UIView *view = [[UIView alloc] initWithFrame:rect];//创建一个视图对象
    CAGradientLayer *viewlayer =[CAGradientLayer layer];//新建一个渐变层
    viewlayer.frame = view.frame;//设置渐变层的位置和尺寸，与视图对象一致
    CGContextRef fromcolor = [UIColor yellowColor].CGColor;//渐变的开始颜色
    CGContextRef midcolor = [UIColor redColor].CGColor;//中间颜色
    CGContextRef tocolor = [UIColor purpleColor].CGColor;//结束颜色
<div class="language- extra-class"><pre><code>viewlayer.colors = [NSArray arrayWithObjects:(__bridge id)(fromcolor), midcolor,tocolor,nil];//将渐变层颜色数组属性，设置y为由三个颜色所构建的数组
[view.layer addSublayer:viewlayer];//将配置好的渐变层添加到视图对象层
[self.view addSubview:view];
</code></pre></div><div class="language- extra-class"><pre class="language-text"><code>&lt;img :src=&quot;$withBase('/shitu05.png')&quot; alt=&quot;foo&quot;&gt; 
## 基本语法
### import指令
1）以#开头，是一个预处理指令，预处理指令表示在编译之前执行
2）作用：是#include指令的增强版。用于包含文件。将文件的内容拷贝到写指令的地方。
3）增强：同一个文件无论#import多少次，只会包含一次该文件
如果#include指令执行多少次就会包含多少次，当然想要实现与#import一样的效果必须配合条件编译指		 令来实现。
4）简要原理：#import指令在包含文件的时候，底层会先判断这个文件是否被包含，如果被包含就会略过，否则会包含。 
### 框架
1）一个功能集  ——苹果或者第三方事先将一些程序在来发程序的时候经常要用到的功能事先写好。把这些功能封装在1个1个的类或者函数之中，这些函数和类的集合叫做框架。
2）Foundation框架
Foundation：基础，这个框架提供了一些最基础的功能 输入输出、一些数据类型
@autoreleasepool是自动释放池
### NSLog函数
1）作用：是printf函数的增强版，向控制台输出信息
2）语法：
                   NSLog(@&quot;格式控制字符串&quot;,变量列表)
      最简单的语法：
                  NSLog(@&quot;要输出的信息&quot;)   
3）增强：
       a.输出一些调试相关的信息    【时间、程序名称、进程编号：线程编号】NSLog输出的信息
       b.会自动换行
       c.OC新增了一些数据类型
### NSString
OC字符串常量必须使用1个@前缀符号，
NSString类型的指针变量，只能储存OC字符串的地址
NSString *str;指针变量前面要加一个星号
NSString *str=@&quot;jack&quot;;
### 注意
OC字符串必须加@符号——NSLog(@&quot;你好&quot;)
如果要使用占位符做字符串拼接要使用%@
NSLog(@&quot;你好，我是%@&quot;,str)
NS前缀
 OC语言的发展：NextStep——》Cocoa——》Foundation框架之中
就是以NextStep命名的前缀
### @符号
1）将C字符串转换为OC字符串
&quot;jack&quot; =》 @&quot;jack&quot;
2）OC中的绝大部分关键字都是以@符号开头

1.OC程序的命令行-编译、连接、执行。
1）.在.m文件中写上符合OC语法规范的源代码
2）.使用编译器将源代码编译为目标文件
     cc  -c xx.m
     a.预处理
     b.检查语法
     c.编译
3）.链接
     cc  xx.o
     如果程序中使用到框架中的函数或者类，那么在链接的时候，必须告诉编译器去那个框架中找这个函数或者类。 
     cc  xx.o  -framework  框架名
     程序中用到那个框架中的功能，那么就在那个地方告诉编译器 
4）.链接成功以后，就会生成1个a.out可执行文件，执行就可以
2.OC程序和C程序各个阶段的后缀名对比
              源文件             目标文件         可执行文件
C                .c                        .o                    .out
OC             .m                        .o                    .out
3.OC中的数据类型
1）.OC中支持C语言中的所有数据类型。
a.基本数据类型
int 	double	float	 	char
b.构造类型
数组		结构体	枚举
c.指针类型
int  *p1
d.空类型
void
e.typedef自定义类型
给已有的数据类型去一个别名
2）.BOOL类型
1）可以存储YES或者NO中任意一个数据，要大写
2）.一般情况下BOOL类型的变量用来存储条件表达式的结果是否成立
3）.BOOL的本质
typedef  signed char BOOL
实际上BOOL类型的变量 是一个有符号的char变量

#define YES ((BOOL)1)     		
#define NO   ((BOOL)0)
 
YES   实际是1
NO     实际是0
3）.Boolean类型
a.可以存储true 或者flase
b.一般情况下Boolean类型的变量用来存储条件表达式的结果是否成立
c.本质
    typedef  unsigned char Boolean   是一个无符号的char类型
       define YES   1     		
define NO     0
4）.class类型、类
5）.id类型  万能指针
6）.nil与NULL差不多
7）.SEL方法选择器
8）.block代码段类型
面向过程与面向对象
其实是解决同一个问题的不同的两种思路。注重的过程或者对象
1）.面向过程
在遇到一个需求的时候，实现这个需求的每一个步骤都是自己写代码亲自一步一步的走
2）.面向对象
在遇到一个需求的时候，不用亲自去实现，而是找一个专门做这个事情的人来帮助我们完成
### 优缺点分析：
C语言是一门面向过程的语言
OC语言是一门面向对象的语言

面向过程的缺点：后期的维护和修改不方便
面向对象的优点：后期的维护和修改十分方便
面向对象的思维解决问题
当你遇到一个需求的时候，不要亲自去实现。
1）.先看看有没有现成的人专门做这件事情。例如框架。
2）.如果没有就自己造一个拥有这样功能的人。可以多次使用
### 类和对象
对象：是现实生活中一个具体存在，看得见、摸得着，拿过来就可以用
类：物以类聚  人以群分
是对一群具有相同特征或者行为的事物的统称
类和对象的关系：
类是模板，类的对象是根据这个模板创建出来的
类模板中有什么，对象中就有什么 绝不可能多 也绝不可能少
如何设计有一个类
类的作用：用来描述一群具有相同特征和行为的事物
设计类的三要素：
类的名字：要描述的这类事物叫什么名字
这类事物具有相同的特征。拥有什么
这类事物具有的共同的行为，做什么
如何找到类
名词提炼法：分析整个业务流程，分析出现哪些名词，这些名词就是类
先有类还是先有对象：
从现实的角度  一定是先有对象再有类
从现实的角度  一定是先有类在有对象
 定义类的语法
a.写在源文件之中 不要写在man函数中
b.类的定义分为两个部分
类的声明
```objectivec
@inteface 类名  ：NSObject
{
//这类事物具有相同的特征，将他们定义为变量
}
//功能就是一个方法，将方法的声明写在这儿
@end
</code></pre></div><p>类的实现</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token keyword">@implementation</span>  类名
将方法的实现写在这里
<span class="token keyword">@end</span>
</code></pre></div><p>》几点注意：
a.类必须要有声明和实现，
b.类名用你描述的事物的名称来命名，不过名字必须是首字母大写
c.用来表示事物特征的变量（属性、成员变量、实例变量等叫法），要放在{}之中
d.为类定义属性的时候，定义的属性名一下划线开头，是一种开发规范
e.类是没法直接使用的，非要使用这个类的话，要先使用这个类中的一个具体存在，再使用这个	     			对象
》如何创建一个类的对象呢？
语法：类名 *对象名 = [类名 new]
在main里面写
Person *p1 = [Person new]
》如何使用对象
如何去访问对象里面的属性：
1）.默认情况下，不允许直接访问对象里面的属性
如果允许对象的属性可以被外界访问，那么就在声明属性的时候加一个@public关键字
2）.访问对象的属性的方式
平时使用：
对象名-&gt;属性名=值；//赋值
对象名-&gt;属性名；//找到属性名的值
p1-&gt;_name=@&quot;小王&quot;
另外一种方法：
(*对象名).属性名=值；
(*p1)._name=@&quot;小王&quot;</p> <h3 id="类的声明"><a href="#类的声明" class="header-anchor">#</a> 类的声明</h3> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token keyword">@interface</span> Person <span class="token punctuation">:</span>NSObject
<span class="token punctuation">{</span>
<span class="token keyword">@public</span>			<span class="token comment">//允许对象访问属性</span>
NSString <span class="token operator">*</span>_name<span class="token punctuation">;</span>
<span class="token keyword">int</span> _age<span class="token punctuation">;</span>
<span class="token keyword">float</span> _height<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
方法的声明写的位置
<span class="token keyword">@end</span>
类的实现
<span class="token keyword">@implementation</span> Person
方法的实现
<span class="token keyword">@end</span>
</code></pre></div><p>占位符：%@    %d
方法的声明实现调用
方法和函数都表示对象的一个功能，OC的行为我们用方法来表示
1）无参数的方法
声明：
位置：在@interface Person :NSObject{}之外
语法：- (返回值类型)方法名称</p> <ul><li>(void)run   //该方法如果没有返回值没有返回值，则使用void
实现：
位置：在@implementation Person之中
语法：将方法的声明拷贝到@implementation之中，去掉分号，追加一个大括号，在大括号中写</li> <li>(void)run{
NSLog(@&quot;我是人，我在跑&quot;)
}
调用：
a.方法是无法直接调用的，因为类是不能直接使用的，必须要先创建对象。那么这个对象中就有类中的属性和方法了  就可以调用对象的方法了
b.调用对象的方法：
[对象名 方法名]
Person *p1 = [Person new]//声明一个对象
[p1 run]//调用
2）带一个参数的方法
声明：
位置：在@interface Person :NSObject{}之外
语法：- (返回值类型)方法名称:(参数的类型)形参的名称</li> <li>(void)eat:(NSString <em>) foodName  //NSString指针加</em>，定义了一个没有返回值的方法，方法的名字叫eat:,有一个参数，类型是NSString * 参数名foodName
实现：
位置：在@implementation Person之中
语法：将方法的声明拷贝到@implementation之中，去掉分号，追加一个大括号，在大括号中写</li></ul> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span>eat<span class="token punctuation">:</span><span class="token punctuation">(</span>NSString <span class="token operator">*</span><span class="token punctuation">)</span> foodName<span class="token punctuation">{</span>
 	<span class="token function">NSLog</span><span class="token punctuation">(</span><span class="token string">@&quot;你给的%@好吃&quot;</span>，foodName<span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre></div><p>调用：
a.方法是无法直接调用的，因为类是不能直接使用的，必须要先创建对象。那么这个对象中就有类中的属性和方法了  就可以调用对象的方法了
b.调用对象的方法：
[对象名 方法名：实参]
Person *p1 = [Person new]//声明一个对象
[p1 eat:@&quot;红烧排骨&quot;]//调用
3)带多个参数的方法
声明：
位置：在@interface Person :NSObject{}之外
语法：- (返回值类型)方法名称:(参数的类型)形参名称1 :(参数的类型)形参名称2  :(参数的类型)形参名称3</p> <ul><li>(int)sum:(int) num1 :(int) num2
表示声明了1个方法，这个方法的返回值类型是int类型的，方法名称叫做 sum: :
有两个参数 参数类型都是int类型 参数名称叫做num1 num2
实现：
位置：在@implementation Person之中
语法：将方法的声明拷贝到@implementation之中，去掉分号，追加一个大括号，在大括号中写</li> <li>(int)sum:(int) num1 :(int) num2 {
int num3=num1+num2;
return num3
}
调用：
a.方法是无法直接调用的，因为类是不能直接使用的，必须要先创建对象。那么这个对象中就有类中的属性和方法了  就可以调用对象的方法了
b.调用带多个参数的语法：
[对象名 方法名：实参1 ：实参2]
Person *p1 = [Person new]//声明一个对象
int sum = [p1 sum:10 :20]//调用
NSLog(@&quot;sum=%d&quot;,sum)
4)带参数的方法声明的规范：
1）如果方法只有一个参数，要求最好这个方法的名字叫做xxxWith:  或者xxxWithxxx
这样写就会看起来像一条完整的语句，提高代码的阅读性
2)如果方法有多个参数，方法名最好是
方法名With:(参数类型)参数名称1 and:(参数类型)参数名称2  and:(参数类型)参数名称3
- (int)sumWith:(int) num1 and :(int) num2
更详细的写法：
方法名With参数1:(参数类型)参数名称1 and参数2:(参数类型)参数名称2<br>
- (int)sumWithNum1:(int) num1 andNum2 :(int) num2</li></ul> <h2 id="常用控件"><a href="#常用控件" class="header-anchor">#</a> 常用控件</h2> <h3 id="button控件"><a href="#button控件" class="header-anchor">#</a> Button控件</h3> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code>    bt1<span class="token punctuation">.</span>frame <span class="token operator">=</span>  <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">130</span><span class="token punctuation">,</span><span class="token number">80</span><span class="token punctuation">,</span><span class="token number">40</span><span class="token punctuation">,</span><span class="token number">40</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//设置按钮位置</span>
    UIButton <span class="token operator">*</span>bt2 <span class="token operator">=</span> <span class="token punctuation">[</span>UIButton buttonWithType<span class="token punctuation">:</span>UIButtonTypeRoundedRect<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置一个普通的圆角按钮</span>
    bt2<span class="token punctuation">.</span>frame <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">80</span><span class="token punctuation">,</span> <span class="token number">180</span><span class="token punctuation">,</span> <span class="token number">150</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    bt2<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor purpleColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的背景色</span>
   bt2<span class="token punctuation">.</span>tintColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor yellowColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的前景颜色</span>
    <span class="token punctuation">[</span>bt2 setTitle<span class="token punctuation">:</span><span class="token string">@&quot;按钮2&quot;</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的标题文字</span>
    <span class="token punctuation">[</span>bt2 addTarget<span class="token punctuation">:</span><span class="token keyword">self</span> action<span class="token punctuation">:</span><span class="token keyword">@selector</span><span class="token punctuation">(</span>buttontap<span class="token punctuation">:</span><span class="token punctuation">)</span> forControlEvents<span class="token punctuation">:</span>UIControlEventTouchUpInside<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//给按钮绑定点击的动作</span>
    UIButton <span class="token operator">*</span>bt3 <span class="token operator">=</span> <span class="token punctuation">[</span>UIButton buttonWithType<span class="token punctuation">:</span>UIButtonTypeRoundedRect<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置一个普通的圆角按钮</span>
    bt3<span class="token punctuation">.</span>frame <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">80</span><span class="token punctuation">,</span> <span class="token number">280</span><span class="token punctuation">,</span> <span class="token number">150</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    bt3<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor brownColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的背景色</span>
    bt3<span class="token punctuation">.</span>tintColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor whiteColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的前景颜色</span>
    <span class="token punctuation">[</span>bt2 setTitle<span class="token punctuation">:</span><span class="token string">@&quot;按钮3&quot;</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的标题文字</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>masksToBounds<span class="token operator">=</span>YES<span class="token punctuation">;</span><span class="token comment">//给按钮添加边框效果</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>cornerRadius<span class="token operator">=</span><span class="token number">10</span><span class="token punctuation">;</span><span class="token comment">//设置圆角半径</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>borderWidth<span class="token operator">=</span><span class="token number">4</span><span class="token punctuation">;</span><span class="token comment">//宽度</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>borderColor<span class="token operator">=</span><span class="token punctuation">[</span>UIColor lightGrayColor<span class="token punctuation">]</span><span class="token punctuation">.</span>CGColor<span class="token punctuation">;</span><span class="token comment">//设置按钮层边框的颜色浅灰</span>

    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt1<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt2<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt3<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>
<span class="token operator">-</span> <span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span> buttontap<span class="token punctuation">:</span><span class="token punctuation">(</span>UIButton <span class="token operator">*</span><span class="token punctuation">)</span>button
<span class="token punctuation">{</span>
   UIAlertController <span class="token operator">*</span>alert <span class="token operator">=</span> <span class="token punctuation">[</span>UIAlertController alertControllerWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;信息&quot;</span> message<span class="token punctuation">:</span><span class="token string">@&quot;警告！！！&quot;</span> preferredStyle<span class="token punctuation">:</span>UIAlertControllerStyleAlert<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//警告弹出窗口</span>
   UIAlertAction <span class="token operator">*</span>okaction <span class="token operator">=</span><span class="token punctuation">[</span>UIAlertAction actionWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;关闭&quot;</span> style<span class="token punctuation">:</span>UIAlertActionStyleDefault handler<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个按钮，作为提示窗口的q确定按钮，当用户点击该按钮时，将关闭提示窗口</span>
   <span class="token punctuation">[</span>alert addAction<span class="token punctuation">:</span>okaction<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到提示窗口</span>
   <span class="token punctuation">[</span><span class="token keyword">self</span> presentViewController<span class="token punctuation">:</span>alert  animated<span class="token punctuation">:</span>YES completion<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//</span>
<span class="token punctuation">}</span>
</code></pre></div><h3 id="图片按钮"><a href="#图片按钮" class="header-anchor">#</a> 图片按钮</h3> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code>    UIButton <span class="token operator">*</span>bt2 <span class="token operator">=</span> <span class="token punctuation">[</span>UIButton buttonWithType<span class="token punctuation">:</span>UIButtonTypeRoundedRect<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置一个普通的圆角按钮</span>
    bt2<span class="token punctuation">.</span>frame <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">31</span><span class="token punctuation">,</span> <span class="token number">180</span><span class="token punctuation">,</span> <span class="token number">150</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    UIImage <span class="token operator">*</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;01&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>bt2 setBackgroundImage<span class="token punctuation">:</span>image forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//指定为正常状态下的背景图片</span>
    <span class="token punctuation">[</span>bt2 setTitle<span class="token punctuation">:</span><span class="token string">@&quot;按钮2&quot;</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的标题文字</span>
    <span class="token punctuation">[</span>bt2 setTitleColor<span class="token punctuation">:</span><span class="token punctuation">[</span>UIColor whiteColor<span class="token punctuation">]</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//标题颜色</span>
    bt2<span class="token punctuation">.</span>titleLabel<span class="token punctuation">.</span>font <span class="token operator">=</span> <span class="token punctuation">[</span>UIFont fontWithName<span class="token punctuation">:</span><span class="token string">@&quot;Arail&quot;</span> size<span class="token punctuation">:</span><span class="token number">24</span><span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//文字字体与大小</span>
    <span class="token punctuation">[</span>bt2 addTarget<span class="token punctuation">:</span><span class="token keyword">self</span> action<span class="token punctuation">:</span><span class="token keyword">@selector</span><span class="token punctuation">(</span>buttontap<span class="token punctuation">:</span><span class="token punctuation">)</span> forControlEvents<span class="token punctuation">:</span>UIControlEventTouchUpInside<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//给按钮绑定点击的动作</span>

    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt2<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token operator">-</span> <span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span> buttontap<span class="token punctuation">:</span><span class="token punctuation">(</span>UIButton <span class="token operator">*</span><span class="token punctuation">)</span>bt
<span class="token punctuation">{</span>
    UIAlertController <span class="token operator">*</span>alert <span class="token operator">=</span> <span class="token punctuation">[</span>UIAlertController alertControllerWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;信息&quot;</span> message<span class="token punctuation">:</span><span class="token string">@&quot;警告！！！&quot;</span> preferredStyle<span class="token punctuation">:</span>UIAlertControllerStyleAlert<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//警告弹出窗口</span>
    UIAlertAction <span class="token operator">*</span>okaction <span class="token operator">=</span><span class="token punctuation">[</span>UIAlertAction actionWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;关闭&quot;</span> style<span class="token punctuation">:</span>UIAlertActionStyleDefault handler<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个按钮，作为提示窗口的q确定按钮，当用户点击该按钮时，将关闭提示窗口</span>
    <span class="token punctuation">[</span>alert addAction<span class="token punctuation">:</span>okaction<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到提示窗口</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span> presentViewController<span class="token punctuation">:</span>alert  animated<span class="token punctuation">:</span>YES completion<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="开发问题"><a href="#开发问题" class="header-anchor">#</a> 开发问题</h2> <h3 id="解决uitableview中cell重用"><a href="#解决uitableview中cell重用" class="header-anchor">#</a> 解决UITableView中Cell重用</h3> <p>tableView的常规配置，当超出一屏的cell就会标上可重用的标识出列到可重用缓存池中，后面再根据可重用标识来到的可重的cell就会和前面显示同样内容。</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath <span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>

    <span class="token comment">// 定义唯一标识</span>

    <span class="token keyword">static</span> NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token string">@&quot;Cell&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">// 通过唯一标识创建cell实例</span>

    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView dequeueReusableCellWithIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    <span class="token comment">// 对cell 进行简单地数据配置</span>

   cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

  cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

  cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

  <span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre></div><p>方法一： 取消cell的重用机制，通过indexPath来创建cell 将可以解决重复显示问题 不过这样做相对于大数据来说内存就比较吃紧了,通过不让它重用cell，来解决重复显示</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath <span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>

    <span class="token comment">// 定义唯一标识</span>

    <span class="token keyword">static</span> NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token string">@&quot;Cell&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">// 通过indexPath创建cell实例 每一个cell都是单独的</span>

    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span>indexPath<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
 cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    <span class="token comment">// 对cell 进行简单地数据配置</span>

    cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

    cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

    cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre></div><p>方法二： 让每个cell都拥有一个对应的标识 这样做也会让cell无法重用 所以也就不会是重复显示了 显示内容比较多时内存占用也是比较多的和方案一类似，同样通过不让它重用cell来解决重复显示，不同的每个cell对应一个重用标识</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath<span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>
    <span class="token comment">// 定义cell标识  每个cell对应一个自己的标识</span>
    NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token punctuation">[</span>NSString stringWithFormat<span class="token punctuation">:</span><span class="token string">@&quot;cell%ld%ld&quot;</span><span class="token punctuation">,</span>indexPath<span class="token punctuation">.</span>section<span class="token punctuation">,</span>indexPath<span class="token punctuation">.</span>row<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 通过不同标识创建cell实例</span>
    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView dequeueReusableCellWithIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>


<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// 对cell 进行简单地数据配置</span>
    cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>
    cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>
    cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre></div><p>方法三： 只要最后一个显示的cell内容不为空，然后把它的子视图全部删除，等同于把这个cell单独出来了 然后跟新数据就可以解决重复显示，同样通过不让他重用cell来解决重复显示，不同的每个cell对应一个标识。</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath <span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>

    <span class="token comment">// 定义唯一标识</span>

    <span class="token keyword">static</span> NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token string">@&quot;Cell&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">// 通过唯一标识创建cell实例</span>

    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView dequeueReusableCellWithIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>

<span class="token comment">//当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免</span>

<span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token punctuation">[</span>cell<span class="token punctuation">.</span>contentView<span class="token punctuation">.</span>subviews lastObject<span class="token punctuation">]</span> <span class="token operator">!=</span> nil<span class="token punctuation">)</span> <span class="token punctuation">{</span>

 <span class="token punctuation">[</span><span class="token punctuation">(</span>UIView <span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">[</span>cell<span class="token punctuation">.</span>contentView<span class="token punctuation">.</span>subviews lastObject<span class="token punctuation">]</span> removeFromSuperview<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token comment">// 对cell 进行简单地数据配置</span>

cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>    

<span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre></div><h3 id="afnetworking-v3-0-封装和使用"><a href="#afnetworking-v3-0-封装和使用" class="header-anchor">#</a> AFNetworking V3.0+ 封装和使用</h3> <p>AFNetworking是一个非常方便的iOS网络请求库，可以轻松实现网络请求。这里只实现AFNetworking框架的一丁点功能，不过也够开发一个app了。可以实现的请求方式：POST / GET / PUT / PATCH / DELETE；也可以加载网络图片等。可回调成功和失败结果。封装类在github上的AFNetworkingDemo上，里面的代码可能随着AFNetworking更新而更新，可下载直接使用。</p> <p>第一步：从github上面下载AFNetworking库，https://github.com/AFNetworking/AFNetworking
第二步：将下面的文件导入自己搭建的工程里面!
<img src="/blog/AFNetworking01.png" alt="foo">
第三步：要新建一个类，用来管理AFNetworking，这个类的代码在网上很多，可以自行查阅，我自己用的是，AFNetworking_RequestData.m和AFNetworking_RequestData.h，新建一个AFNetworking_RequestData文件夹将这两个文件导入。之后我们需要发送网络请求，调用接口的时候就#import &quot;AFNetworking_RequestData.h&quot;。 第四步：配置支持IOS9，Xcode7的http请求 找到Info.plist文件，右键Open As-Source Code。添加NSAppTransportSecurity项。代码如下：</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code><span class="token operator">&lt;</span>key<span class="token operator">&gt;</span>NSAppTransportSecurity<span class="token operator">&lt;</span><span class="token operator">/</span>key<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>dict<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>key<span class="token operator">&gt;</span>NSAllowsArbitraryLoads<span class="token operator">&lt;</span><span class="token operator">/</span>key<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>true<span class="token operator">/</span><span class="token operator">&gt;</span> <span class="token operator">&lt;</span><span class="token operator">/</span>dict<span class="token operator">&gt;</span>  
</code></pre></div><img src="/blog/AFNetworking02.png" alt="foo">
第五步：在需要进行网络请求的地方，#import &quot;AFNetworking_RequestData.h&quot; 举例：#import &quot;AFNetworking_RequestData.h&quot;
<p>请求url -- #define Game_Timer @&quot;http://live.3g.qq.com/g/s?aid=action_api&amp;module=nba&amp;action=schedule&amp;md=&amp;ds=5&amp;sid=&quot; ///--在点击事件中调用方法，这个方法里面执行下面几句话： [AFNetworking_RequestData requestMethodGetUrl:Game_Timer dic:nil Succed:^(id responseObject) { NSLog(@&quot;%@&quot;,responseObject); } failure:^(NSError *error) { NSLog(@&quot;%@&quot;,error); }];</p> <h4 id="afnetworking-请求头的配置用来完成http-basic-auth的鉴权"><a href="#afnetworking-请求头的配置用来完成http-basic-auth的鉴权" class="header-anchor">#</a> AFNetWorking 请求头的配置用来完成HTTP Basic Auth的鉴权</h4> <p>AFNetWorking 请求头的配置用来完成HTTP Basic Auth的鉴权</p> <p>前文中有关于使用AFNetWorking这个代码库来搭建项目的网络协议，但是缺少关于网络请求头方面的知识，现在将其完善。</p> <p>AFNetWorking 3.0之前设置请求头：</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code>
perationManager <span class="token operator">*</span>manager <span class="token operator">=</span> <span class="token punctuation">[</span>AFHTTPRequestOperationManager manager<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>securityPolicy <span class="token operator">=</span> <span class="token punctuation">[</span>AFSecurityPolicy policyWithPinningMode<span class="token punctuation">:</span>AFSSLPinningModeNone<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer <span class="token operator">=</span> <span class="token punctuation">[</span>AFJSONRequestSerializer serializer<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>responseSerializer <span class="token operator">=</span> <span class="token punctuation">[</span>AFJSONResponseSerializer serializer<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;application/json&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Accept&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;application/json; charset=utf-8&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Content-Type&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

AFNetWorking <span class="token number">3.0</span>之后设置请求头，更加详细，POST和GET都可以：

<span class="token operator">-</span><span class="token punctuation">(</span>AFHTTPSessionManager<span class="token operator">*</span><span class="token punctuation">)</span>defaultHTTPManager
<span class="token punctuation">{</span>
    <span class="token comment">// 初始化对象</span>
    AFHTTPSessionManager <span class="token operator">*</span>manager <span class="token operator">=</span> <span class="token punctuation">[</span>AFHTTPSessionManager manager<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 返回的格式 JSON</span>
    manager<span class="token punctuation">.</span>responseSerializer <span class="token operator">=</span> <span class="token punctuation">[</span>AFJSONResponseSerializer serializer<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 可接受的文本参数规格</span>
    manager<span class="token punctuation">.</span>responseSerializer<span class="token punctuation">.</span>acceptableContentTypes <span class="token operator">=</span>  <span class="token punctuation">[</span>NSSet setWithObjects<span class="token punctuation">:</span><span class="token string">@&quot;application/json&quot;</span><span class="token punctuation">,</span> <span class="token string">@&quot;text/html&quot;</span><span class="token punctuation">,</span><span class="token string">@&quot;text/json&quot;</span><span class="token punctuation">,</span><span class="token string">@&quot;text/javascript&quot;</span><span class="token punctuation">,</span> nil<span class="token punctuation">]</span><span class="token punctuation">;</span>
    
    <span class="token comment">// 开始设置请求头</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;application/json&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Content-Type&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;填写系统版本&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;sysVersion&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;填写设备&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;deviceModel&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;填写App版本&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;appVersion&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    
    <span class="token comment">// uid是每个用户对应的ID  cipherText是密码</span>
    NSString <span class="token operator">*</span> part1 <span class="token operator">=</span> <span class="token punctuation">[</span>NSString stringWithFormat<span class="token punctuation">:</span><span class="token string">@&quot;%lld:%@&quot;</span><span class="token punctuation">,</span>uid<span class="token punctuation">,</span>cipherText<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 通过 ID ：密码 的格式，用Basic 的方式拼接成字符串</span>
    NSString <span class="token operator">*</span> authorization <span class="token operator">=</span> <span class="token punctuation">[</span>NSString stringWithFormat<span class="token punctuation">:</span><span class="token string">@&quot;Basic %@&quot;</span><span class="token punctuation">,</span><span class="token punctuation">[</span>part1 base64Encode<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 设置Authorization的方法设置header</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span>authorization forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Authorization&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 或者直接调用AF的方法进行设置</span>
<span class="token comment">//    - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username</span>
<span class="token comment">//       password:(NSString *)password</span>
<span class="token comment">//    {</span>
<span class="token comment">//        NSData *basicAuthCredentials = [[NSString stringWithFormat:@&quot;%@:%@&quot;, username, password] dataUsingEncoding:NSUTF8StringEncoding];</span>
<span class="token comment">//        NSString *base64AuthCredentials = [basicAuthCredentials base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0];</span>
<span class="token comment">//        [self setValue:[NSString stringWithFormat:@&quot;Basic %@&quot;, base64AuthCredentials] forHTTPHeaderField:@&quot;Authorization&quot;];</span>
<span class="token comment">//    }</span>
    <span class="token keyword">return</span> manager<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre></div><p>其实最重要的注释中设置请求部分。</p> <p>我们可以在前面关于使用AFNetWorking配置网络请求的文章中，AFNetworking_RequestData.m文件中设置头文件。
<img src="/blog/AFNetworking03.png" alt="foo">
此处只是写死的两个头请求。</p> <h3 id="afnetworking3-0带参数请求体以及带请求头"><a href="#afnetworking3-0带参数请求体以及带请求头" class="header-anchor">#</a> AFNetworking3.0带参数请求体以及带请求头</h3> <p>关于使用AFNetworking3.0带参数请求体以及带请求头的自己封装</p> <p>在这里请允许我发句牢骚，真的难搞，不过我首先说好AFNetworking库应该是一个很好的库了。</p> <p>首先最重要的一点是：parameters:dic 这句代码中请求体dic我们只需要传NSDictionary *paramDict = @{@&quot;mobile&quot;:mobile,@&quot;pwd&quot;:pwd};类似的对象就可以了，因为AFNetworking库会自动对其序列化。 我与服务器的约定是在新建两个请求头，一个头是当前时间戳，一个是当前时间戳+请求体+一个固定字符串 困扰我很久的其实是以下几点： 第一点：请求头中[manager.requestSerializer setValue:@&quot;application/x-www-form-urlencoded&quot; forHTTPHeaderField:@&quot;Content-Type&quot;];应该是设置application/x-www-form-urlencoded&quot;，而不是application/json&quot; 第二点其实还是请求头，问题就是出在请求体中。NSDictionary *paramDict = @{@&quot;mobile&quot;:mobile,@&quot;pwd&quot;:pwd};这句话得到的是一个带有空格的对象，所以parameters:dic会是一个带空格的对象。 这里我们需要自己写一个方法将对象拼接成json字符串，</p> <p>NSDictionary 转Json 去掉换行去掉空格</p> <p>//系统自带</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code>NSError <span class="token operator">*</span> error<span class="token punctuation">;</span>
 NSData <span class="token operator">*</span> jsonData <span class="token operator">=</span> <span class="token punctuation">[</span>NSJSONSerialization dataWithJSONObject<span class="token punctuation">:</span>dictionary options<span class="token punctuation">:</span>kNilOptions error<span class="token punctuation">:</span><span class="token operator">&amp;</span>error<span class="token punctuation">]</span><span class="token punctuation">;</span>
 NSString <span class="token operator">*</span> jsonStr <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>NSString alloc<span class="token punctuation">]</span> initWithData<span class="token punctuation">:</span>jsonData encoding<span class="token punctuation">:</span>NSUTF8StringEncoding<span class="token punctuation">]</span><span class="token punctuation">;</span>
</code></pre></div><p>这个会将对象转化成字符串，也就是序列化，但是还是有空格存在，所以是不可取的。</p> <p>//自定义一个</p> <div class="language- extra-class"><pre class="language-text"><code>NSString *jsonStr = @&quot;{&quot;;
    NSArray * keys = [dictionary allKeys];
    for (NSString * key in keys) {
        jsonStr = [NSString stringWithFormat:@&quot;%@\&quot;%@\&quot;:\&quot;%@\&quot;,&quot;,jsonStr,key,[dictionary objectForKey:key]];
    }
    jsonStr = [NSString stringWithFormat:@&quot;%@%@&quot;,[jsonStr substringWithRange:NSMakeRange(0, jsonStr.length-1)],@&quot;}&quot;];
</code></pre></div><p>那么现在问题又来了，就是，NSDictionary allkeys或者allvalues取出来的数组是乱序的。 使用得到所有的key的数组后是一个无序的集合，如果我们需要正确的显示出它在此之前的顺序 ，可以通过检索来实现。</p> <div class="language-objectivec extra-class"><pre class="language-objectivec"><code>NSArray <span class="token operator">*</span> keys <span class="token operator">=</span> <span class="token punctuation">[</span>dic allKeys<span class="token punctuation">]</span><span class="token punctuation">;</span>
    NSArray <span class="token operator">*</span>sortedKeys <span class="token operator">=</span> <span class="token punctuation">[</span>keys sortedArrayUsingSelector<span class="token punctuation">:</span><span class="token keyword">@selector</span><span class="token punctuation">(</span>caseInsensitiveCompare<span class="token punctuation">:</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
</code></pre></div><p>这样子我们就可以去做关于请求头的拼接</p> <h3 id="xcode-控制台打印unicode字符串转换为中文"><a href="#xcode-控制台打印unicode字符串转换为中文" class="header-anchor">#</a> Xcode 控制台打印Unicode字符串转换为中文</h3> <p>Xcode 控制台打印Unicode字符串转换为中文</p> <p>当通过接口获取到服务器的值时，最恶心的事情发生在控制台。</p> <p>在Xcode的控制台里直接打印一个数组或者字典,输出的都是一些Unicode的编码,不方便调试. 要想看到中文,则要去获取对应的key或者数组下标.得到具体某一个对象才能看到中文,给我们调试起来很不方便.</p> <p>而现在可以使用LYLUnicode输出中文, 使用也方便.代码也简洁,就几行代码. 直接把LYLUnicode拖到工程里就能让Xcode支持中文的输出了.</p> <p>就这么简单的一行输出,不需要任何更改.,使用之前Xcode控制台是打印的Unicode编码, 把LYLUnicode拖进来之后,不做任何操作,输出的内容就是我们想看到的中文了.</p> <p>Github是个好东西---------- githud地址：https://github.com/allencelee/LYLUnicode 我们通过上面的地址进入，下载下来，我们只取LYLUnicode文件夹就够了，里面就一个.h与.m文件。然后拖到工程中，重新运行就够了，什么都不需要做。</p> <p>说实话具体原理还是没看懂，如果有兴趣可以去看看这个作者的理解，虽然感觉也没听懂他说的是个什么。 https://www.cnblogs.com/allencelee/p/9400281.html</p> <h3 id="使用xcode出现警告、错误的解决方法总结"><a href="#使用xcode出现警告、错误的解决方法总结" class="header-anchor">#</a> 使用Xcode出现警告、错误的解决方法总结</h3> <p>使用Xcode出现警告、错误的解决方法总结</p> <p>以下是网上总结的一些方法：</p> <p>1，警告：“xoxoxoxo”  is deprecated 解决办法：查看xoxoxoxo的这个方法的文档，替换掉这个方法即可。</p> <p>2，警告：Declaration of &quot;struct sockaddr&quot; will not be visible outside of this function 解决办法：在你的开源.m文件中添加 #import</p> <p>3，警告：Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation' 解决办法：类型不匹配。跳到出错的那一行，UIInterfaceOrientation强制转换为UIDeviceOrientation就行了。</p> <p>4，警告：incompatible pointer types assigning to 'MyArrayList*'from 'NSMutableArray' 解决办法：加入强制转换(MyArrayList*)</p> <p>5，警告：'&amp;&amp;' within '||' 问题出处：     if (exists &amp;&amp; !isDirectory || !exists)………   解决办法： if ((exists &amp;&amp; !isDirectory) || !exists)………</p> <p>6，警告：Warning：The Copy Bundle Resources build phase contains this target's Info.plist file 解决办法：将Info.plist文件移到Resources目录下，而不要直接放在target下。</p> <p>7，警告：在使用ASIHttp…第三方库的，运行报错。 解决办法：看你的项目中是否添加CFNetwork.framework、SystemConfiguration.framework, MobileCoreServices.framework, CoreGraphics.framework和libz.1.2.3.dylib，如果是sdk5.0以上，改添加libz.1.2.5.dylib</p> <p>8，警告：xxxooo，missing required architecture i386 in file  解决办法：如果是错误信息的话：Target-&gt;Build Settings-&gt;Search Paths, 删除FrameworkSearch Paths 里面内容就可以了。 要只是一个警告的话，真机调试可以过。具体解决方法待大神出现。</p> <p>9，警告： clang: error: no such file or directory: '/demo2/控件代码/13/Recorder/Recorder_Prefix.pch' clang: error: no input files Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1 解决办法： 在你的主工程文件 target搜素，pch ，找到Prefix Header    把它后面的值，都删除，再运行就解决了。</p> <p>10，警告： “ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute 解决办法：如果定义了ARC有效，那么必须要有所有者属性的定义;所以代码改成下面这样 @property (nonatomic, strong, readonly) NSString *ss;</p> <p>11，警告： io6一下的xib系统均没有自动选择Use Autolayout， Supporting iOS 5 and below with xib of iOS 6  解决办法：Just un-select “Use Autolayout” in the file inspector of the xib’s view and we are back to the familiar autosizing in size inspector and boom, it supports iOS 5 and below.</p> <p>12，警告： Warning: Multiple build commands for output file xxx.png  解决办法：找到项目里xxx.png重复，删除重复的资源。</p> <p>//以下是升级到 xcode 5.0.1 之后使用遇到的警告 13，警告：  “iOS 模拟器”未能安装此应用程序。 解决办法：删除模拟器上当前要运行那个APP，重新运行项目。就ok</p> <p>14，警告： SpringBoard无法启动应用程序 错误:-3 解决办法：退出模拟器，重新运行这个项目。</p> <p>15，警告： The server certificate failed to verify.    解决办法： 1、打开终端（实用工具 --&gt;终端），在终端中输入如下命令： svn ls https://192.100.1.11?0/svn/xxxxxx（注意下面的url更换成你自己的url地址） 然后直接输入 “ p ”  确认，就可以重新连接了。</p> <p>16，警告： Bitmasking for introspection of Objective-C object pointers is strongly discouraged.    解决办法： 某数字&amp; 0x1的时候是代表要取最低位是否为1，改成了  if(JK_EXPECT_F(((NSUInteger)object)%2))即可。</p> <p>17，警告： Implicit conversion loses integer precision: 'unsigned long' to 'CC_LONG' (aka 'unsigned int').    解决办法：     CC_MD5(str,strlen(str), r);，改成了     CC_MD5(str, (CC_LONG)strlen(str), r);即可。</p> <p>18，警告： error: failed to launch '/private/var/mobile/Applications/xxxxx' -- failed to get the task for process 11140.   解决办法：     重启你的开发手机即可，还有一种可能是你的开发者证书与发布证书搞错了，检查在xcode中证书是否一直 。</p> <p>遇到相关的警告，一般编译器都会提供解决方案，所以，作为新手，我们应该看懂编译器给我们的提示，这样我们解决问题就会事半功倍。</p> <p>1，  错误信息：   &quot;OBJC_CLASS$  xxxxx  &quot;, referenced from:       objc-class-ref in ViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 解决方法：  查看工程，看是不是没有导入相关的框架。或者工程里添加的有相同&quot;.m&quot;,&quot;.h&quot; 文件</p> <p>2，  错误信息： Couldn't register dy.CKRiLiText with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.Current language:  auto; currently objective-c 解决方法： 可能是电脑内存问题引起，重启电脑即可解决。如果重启解决不了问题，那就是你刚刚改动的代码引起的问题。</p> <p>3 、 错误信息： ios 5是调试正常的，ios 6真机调试的时候,出现如下错误：ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/mac4/Desktop/my desktop/My app/MyApp name 20:09:12  /MyApp name/ZBarSDK/libzbar.a for architecture armv7serror: linker command failed with exit code 1 (use -v to see invocation) 解决方法：在Xcode里，点击相应的Target，然后点Build Settings，找到VALID_ARCHS，看里面的是不是arvm7s，如果不是改成arvm7s就可以了。</p> <p>4 、 错误信息：  error: receiver type 'ViewController' for instance message does not declare a method with selector 'hideSearchBar:' [4] ViewController 中没有声明一个方法选择'hideSearchBar： 解决方法： 在ViewController .h 中声明一下这个方法 “ hideSearchBar ”  即可。</p> <p>5、 错误信息：当json从服务端请求时得到的字符串，如果这样写的话，会报错，';' after top level declarator NSString *ss= @&quot;{&quot;recommend&quot;:&quot;世界末日&quot;,&quot;dogname&quot;:&quot;机器人&quot;}&quot;;   解决方法： 就是，把   “   替换成  &quot;  即可。NSString *ss= @&quot;{ &quot;recommend &quot;: &quot;世界末日 &quot;, &quot;dogname &quot;: &quot;机器人 &quot;}&quot;;</p> <p>6 、 错误信息：  error: Existing instance variable '_datasource' for property 'datasource' with  assign attribute must be __unsafe_unretained</p> <p>解决方法：      id _datasource; 改为     __unsafe_unretained id _datasource:即可</p> <p>31，警告：  warning: Semantic Issue: Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'BOOL' (aka 'signed char')</p> <p>解决办法： 检查 BOOL ＊换为BOOL就可以了，检查是不是多写一个   ＊  号。</p> <p>32:Jsonkit中的警告</p> <p>Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass() object-&gt;isa 替换为 object_getClass(object) keyObject-&gt;isa 替换为 object_getClass(keyObject) (id)keys[idx]-&gt;isa 替换为 object_getClass((id)keys[idx])</p> <p>format specifies type 'unsigned long' but the argument has type 'nsuinteger' (aka 'unsigned int') 给变量增加(unsigned long)进行类型转换</p> <p>33：md5加密（iOS SDK中自带了CommonCrypto</p> <p>Implicit declaration of function 'CC_MD5' is invalid in C99</p> <p>[plain] view plaincopy</p> <p>#define CC_MD5_DIGEST_LENGTH 16       +(NSString *)MD5HashForString:(NSString *)input {           const char *cStr = [input UTF8String];           unsigned char result[CC_MD5_DIGEST_LENGTH];           CC_MD5(cStr, strlen(cStr), result);           return [NSString stringWithFormat: @&quot;xxxxxxxxxxxxxxxx&quot;,                   result[0], result[1], result[2], result[3],                   result[4], result[5], result[6], result[7],                   result[8], result[9], result[10], result[11],                   result[12], result[13], result[14], result[15]];       }</p> <p>引入函数定义的头文件</p> <p>#import</p> <p>34:ASIDataDecompressor中的警告</p> <p>format specifies type  'short' but the  argument has type 'int'</p> <p>在+ (NSError *)deflateErrorWithCode:(int)code 和 +(NSError *)inflateErrorWithCode:(int)code中</p> <p>［NSString stringWithFormat:@&quot;Compression of data failed with code %hi&quot;,code] 中</p> <p>将code改为 (short)code,类型转换</p> <p>35：Reachability中警告</p> <p>Using 'stringWithString:' with a literal is redundant</p> <p>statusString = [NSString stringWithString: @&quot;Not Reachable&quot;];</p> <p>改为：statusString = @&quot;Not Reachable&quot;;</p> <p>36.format specifies type 'id' but the argument has type 'const char *'</p> <p>NSCAssert(NO, @&quot;Unhandled error encountered during SAX parse. msg is %@&quot;, msg); 改为：NSCAssert(NO, @&quot;Unhandled error encountered during SAX parse. msg is %@&quot;, [NSString stringWithUTF8String:msg]);</p> <p>37 Using 'stringWithString:' with a literal is redundant 改为：self.locationInput.text = @&quot;captured change&quot;;</p> <p>38 在项目中设置控件的layer属性时，会发生错误, &quot;Property 'c' cannot be found in forward class object 'CALayer *&quot;,</p> <p>这时需要引入  #import 。</p> <p>41,错误</p> <p>Error launching remote program: failed to get the task for process</p> <p>解决方法： 把真机上的软件，删除，然后，clean 一下，重新运行就可以了。</p> <p>42,真机调试的时候，出现   [attachment=49364]   这正常，但是不识别机器的。</p> <p>解决方法：</p> <p>把 ， [attachment=49365] 设置为以上相对应的版本就可以了。</p> <p>43,真机调试的时候，出现   ios Broken pipe</p> <p>解决方法： :推出xcode :断开机器(iphone,ipad,ipod)链接 :重启iPhone在联接xcode，就可以了。</p> <p>iOS真机调试中出现identity(The identity 'iPhone Developer)证书不匹配的问题</p> <p>提示(null) error: could not read CFBundleIdentifier from Info.plist (null)</p> <p>新建一个同名工程，拷贝其plist文件，将原工程中的plist文件替换掉即可。</p></div> <footer class="page-edit" style="display:none;"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">2023/1/14 下午4:29:37</span></div></footer> <!----> <!----> <!----></main> <!----></div></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><div class="kanbanniang" data-v-5775ee02><div class="banniang-container" style="display:;" data-v-5775ee02><div class="messageBox" style="right:68px;bottom:190px;display:none;" data-v-5775ee02>
      我是王茂铭谢谢你的关注 
    </div> <div class="operation" style="right:90px;bottom:40px;display:;" data-v-5775ee02><i class="kbnfont kbn-ban-home ban-home" data-v-5775ee02></i> <i class="kbnfont kbn-ban-message message" data-v-5775ee02></i> <i class="kbnfont kbn-ban-close close" data-v-5775ee02></i> <a target="_blank" href="https://vuepress-theme-reco.recoluan.com/views/plugins/kanbanniang.html" data-v-5775ee02><i class="kbnfont kbn-ban-info info" data-v-5775ee02></i></a> <i class="kbnfont kbn-ban-theme skin" style="display:;" data-v-5775ee02></i></div> <canvas id="banniang" width="240" height="352" class="live2d" style="right:90px;bottom:-20px;opacity:0.9;" data-v-5775ee02></canvas></div> <div class="showBanNiang" style="display:none;" data-v-5775ee02>
    看板娘
  </div></div><canvas id="vuepress-canvas-cursor"></canvas><APlayer audio="" fixed="true" mini="true" autoplay="autoplay" theme="#b7daff" loop="loop" order="random" preload="auto" volume="0.2" mutex="true" lrc-type="1" list-max-height="250" storage-name="vuepress-plugin-meting" id="aplayer-fixed"></APlayer></div></div>
    <script src="/blog/assets/js/app.e4cba77b.js" defer></script><script src="/blog/assets/js/5.1ad0ff24.js" defer></script><script src="/blog/assets/js/1.fe4eac58.js" defer></script><script src="/blog/assets/js/27.0c4acdea.js" defer></script>
  </body>
</html>
